package com.example.springbootorderrabbitmqconsoumer.service;

import com.example.springbootorderrabbitmqconsoumer.config.RabbitXdelayConfig;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@RabbitListener(queues = RabbitXdelayConfig.IMMEDIATE_QUEUE_XDELAY)
public class XdelayMsgReceiver {

    @RabbitHandler
    public void get(String msg) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("当前时间："+sdf.format(new Date()) + " Delay sent.");
        System.out.println("收到延时消息:" + msg);
    }
}
